package org.example.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.example.remote.HelloRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    HelloRemote helloRemote;

    @RequestMapping("/hello/{name}")
    @HystrixCommand(fallbackMethod = "hys")
    public String index(@PathVariable("name") String name) {
        return helloRemote.hello(name);
    }

    public String hys(@PathVariable("name") String name){
        return "this is Hystrix";
    }
}